<?php

namespace common\models\base;

use Yii;

/**
 * This is the model class for table "{{%used_car_estimate_order}}".
 *
 * @property int $id
 * @property int $custom_id
 * @property int $status 状态
 * @property string $serialize_data 其他数据
 *
 * @property Custom $custom
 * @property UsedCarEstimateOrderLog[] $usedCarEstimateOrderLogs
 */
class UsedCarEstimateOrder extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%used_car_estimate_order}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['custom_id'], 'required'],
            [['custom_id', 'status'], 'integer'],
            [['serialize_data'], 'string'],
            [['custom_id'], 'exist', 'skipOnError' => true, 'targetClass' => Custom::className(), 'targetAttribute' => ['custom_id' => 'id']],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app', 'ID'),
            'custom_id' => Yii::t('app', 'Custom ID'),
            'status' => Yii::t('app', '状态'),
            'serialize_data' => Yii::t('app', '其他数据'),
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getCustom()
    {
        return $this->hasOne(Custom::className(), ['id' => 'custom_id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getUsedCarEstimateOrderLogs()
    {
        return $this->hasMany(UsedCarEstimateOrderLog::className(), ['used_car_estimate_order_id' => 'id']);
    }
}
